n = int(input())
a = []
b = []
for i in range(0, n):
    a.append(int(input()))
m = int(input())
for i in range(0, m):
    b.append(int(input()))
a.sort()
b.sort()
R = 0
ans = 0
for i in range(0, n):
    while R < m and a[i] > b[R]:
        R = R + 1
    if R < m and a[i] <= b[R]:
        ans = ans + 1
        R = R + 1    
print(ans)